package it.polimi.travelDreamEJB.basicproductmanagement;

import it.polimi.travelDreamEJB.basicproductmanagement.dto.HotelDTO;
import it.polimi.travelDreamEJB.travelpacketmanagement.DefaultPacket;
import it.polimi.travelDreamEJB.travelpacketmanagement.PersonalizedPacket;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

/**
 * The persistent class for the hotel database table.
 * 
 */
@Entity
@Table(name = "hotel")
@NamedQueries({
		@NamedQuery(name = "Hotel.findAll", query = "SELECT h FROM Hotel h"),
		@NamedQuery(name = "Hotel.find", query = "SELECT h FROM Hotel h WHERE h.destination LIKE :destination AND h.name LIKE :name AND h.price <= :maxPrice AND h.price >= :minPrice AND h.stars <= :maxStars AND h.stars >= :minStars "),
		@NamedQuery(name = "Hotel.possibleCities", query = "SELECT h FROM Hotel h GROUP BY h.destination") })
public class Hotel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_hotel")
	private int idHotel;

	private String destination;

	private String info;

	private String name;

	private int price;

	private int stars;

	// bi-directional many-to-one association to DefaultPacket
	@OneToMany(mappedBy = "hotel", cascade=CascadeType.ALL)
	private List<DefaultPacket> hotelOfDefaultPacket;

	// bi-directional many-to-one association to PersonalizedPacket
	@OneToMany(mappedBy = "hotel", cascade=CascadeType.ALL)
	private List<PersonalizedPacket> hotelOfPersonalizedPacket;

	public Hotel() {
	}

	public Hotel(HotelDTO hotel) {
		this.hotelOfDefaultPacket = new ArrayList<DefaultPacket>();
		this.idHotel = hotel.getId();
		this.destination = hotel.getDestination();
		this.info = hotel.getInfo();
		this.name = hotel.getName();
		this.price = hotel.getPrice();
		this.stars = hotel.getStars();
	}

	public List<PersonalizedPacket> getHotelOfPersonalizedPacket() {
		return hotelOfPersonalizedPacket;
	}

	public void setHotelOfPersonalizedPacket(
			List<PersonalizedPacket> hotelOfPersonalizedPacket) {
		this.hotelOfPersonalizedPacket = hotelOfPersonalizedPacket;
	}

	public int getIdHotel() {
		return this.idHotel;
	}

	public void setIdHotel(int idHotel) {
		this.idHotel = idHotel;
	}

	public String getDestination() {
		return this.destination;
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public String getInfo() {
		return this.info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return this.price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getStars() {
		return this.stars;
	}

	public void setStars(int stars) {
		this.stars = stars;
	}

	public List<DefaultPacket> getHotelOfDefaultPacket() {
		return hotelOfDefaultPacket;
	}

	public void setHotelOfDefaultPacket(List<DefaultPacket> hotelOfDefaultPacket) {
		this.hotelOfDefaultPacket = hotelOfDefaultPacket;
	}

}